package net.monare.mifss.util;

import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import net.monare.mifss.configurations.pojo.ContentPoolDef;
import net.monare.mifss.configurations.pojo.Property;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component

@Lazy(false)
public class PoolFactory {
	
	@Value( "${test.fsPool.location}" )
	private String poolBaseFolder;
	
	public List<ContentPoolDef> generateTestFsPool() throws IOException{

        RandomStringGenerator rsg = new RandomStringGenerator();

		Set<Property> propList = new HashSet<>();
		
		String poolPath =  poolBaseFolder + File.separator + rsg.nextRandomString();
		
		Property prop = new Property("storage_folder", poolPath);
		propList.add(prop);
		
		ContentPoolDef cpd = new ContentPoolDef();
		
		cpd.setProperties(propList);
		cpd.setImplementation("fsContentPoll");
		cpd.setDescription("Pool description");
		cpd.setId(1);
		cpd.setWriteActive(true);
		cpd.setTitle("Pool title");
		
		List<ContentPoolDef> pools = new LinkedList<>();
		pools.add(cpd);
		
		
		return pools;
	}

}
